<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.32">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #cd1713}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #737373}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #008225}
span.s1 {color: #000000}
span.s2 {color: #102ac3}
span.s3 {color: #008225}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><b>Concat<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Concatenative Cross-Synthesis on Live Streams<span class="Apple-converted-space"> </span></b></p>
<p class="p2"><br></p>
<p class="p3"><b>Concat.ar(control, source, storesize, seektime, seekdur, matchlength, freezestore, zcr, lms, sc, st)</b></p>
<p class="p4"><br></p>
<p class="p3">Implementation of concatenative sound synthesis based on matching four features from a control input to the database generated from a source input. The control determines which frames of the source get played back, and you can change the weighting of features to refine your matching criteria (ie, make rms the most heavily weighted to have amplitude as the most important criteria).<span class="Apple-converted-space">  </span>You can also modulate the match length, being the amount of source played back for a match, the feature weightings, and freeze the database collection to work with a collected sample from the source.<span class="Apple-converted-space"> </span></p>
<p class="p4"><br></p>
<p class="p3">Refs- see the publications of Schwarz, Sturm, Casey amongst others.<span class="Apple-converted-space"> </span></p>
<p class="p4"><br></p>
<p class="p3"><b>control</b>- audio rate input, acts as control<span class="Apple-converted-space"> </span></p>
<p class="p3"><b>source</b>- audio rate input, source for cross-synthesis<span class="Apple-converted-space"> </span></p>
<p class="p3"><b>storesize</b>- size of source store sample buffer in seconds</p>
<p class="p3"><b>seektime</b>- Time in seconds into the past to start searching for matches <span class="Apple-converted-space"> </span></p>
<p class="p3"><b>seekdur</b>- Time in seconds from seektime towards the present to test matches</p>
<p class="p3"><b>matchlength</b>- Match length in seconds (this will be rounded to the nearest FFT frame)<span class="Apple-converted-space"> </span></p>
<p class="p3"><b>freezestore</b>- Stop collecting novel source input, keep store (database) fixed</p>
<p class="p3"><b>zcr</b>- Weight for zero crossing rate feature</p>
<p class="p3"><b>lms</b>- Weight for log mean square amplitude feature</p>
<p class="p3"><b>sc</b>- Weight for spectral centroid feature</p>
<p class="p3"><b>st</b>- Weight for spectral tilt feature</p>
<p class="p5"><br></p>
<p class="p6"><br></p>
<p class="p7">//examples</p>
<p class="p6"><br></p>
<p class="p8"><span class="s1">b = </span><span class="s2">Buffer</span><span class="s1">.read(s,</span>"sounds/a11wlk01.wav"<span class="s1">);</span></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">//match only on amplitude from audio in</p>
<p class="p9">(</p>
<p class="p9"><span class="s2">SynthDef</span>(<span class="s3">\concat1</span>, {<span class="s2">arg</span> bufnum, matchlength=0.01, freeze=0;</p>
<p class="p9"><span class="s2">var</span> concat, control, input;</p>
<p class="p6"><br></p>
<p class="p9">control= <span class="s2">SoundIn</span>.ar;</p>
<p class="p6"><br></p>
<p class="p9">input=<span class="s2">PlayBuf</span>.ar(1,bufnum,<span class="s2">BufRateScale</span>.kr(bufnum), loop:1);<span class="Apple-converted-space"> </span></p>
<p class="p6"><br></p>
<p class="p9">concat= <span class="s2">Concat</span>.ar(control,input,1.0,1.0,1.0,matchlength,freeze,0.0,1.0,0.0,0.0);</p>
<p class="p6"><br></p>
<p class="p9"><span class="s2">Out</span>.ar(0,<span class="s2">Pan2</span>.ar(concat,0.0))}).add;</p>
<p class="p9">)</p>
<p class="p6"><br></p>
<p class="p9">a=<span class="s2">Synth</span>(<span class="s3">\concat1</span>,[<span class="s3">\bufnum</span>, b.bufnum]);</p>
<p class="p6"><br></p>
<p class="p9">a.set(<span class="s3">\freeze</span>, 0);</p>
<p class="p6"><br></p>
<p class="p9">a.set(<span class="s3">\matchlength</span>, 0.01);</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">//synthesis controls audio in- beat box, then the synth drives bits of audio rhythmically</p>
<p class="p9">(</p>
<p class="p9">{</p>
<p class="p9"><span class="s2">var</span> concat, control, input;</p>
<p class="p6"><br></p>
<p class="p9">control= <span class="s2">SinOsc</span>.ar(0.5)*<span class="s2">Saw</span>.ar(<span class="s2">SinOsc</span>.kr(<span class="s2">LFNoise0</span>.kr(<span class="s2">MouseY</span>.kr(0.01,1),3,4.5),0,50,<span class="s2">MouseY</span>.kr(120,500)));</p>
<p class="p6"><br></p>
<p class="p9">input=<span class="s2">SoundIn</span>.ar;<span class="Apple-converted-space"> </span></p>
<p class="p6"><br></p>
<p class="p9">concat= <span class="s2">Concat</span>.ar(control,input,4.0,4.0,4.0,<span class="s2">MouseX</span>.kr(0.0,0.5),0,0.5,1.0,0.5,0.0);</p>
<p class="p6"><br></p>
<p class="p9"><span class="s2">Out</span>.ar(0,<span class="s2">Pan2</span>.ar(concat,0.0))}.play</p>
<p class="p9">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">//audio in controls synthesis, low latency, match by ZCR and spec centroid</p>
<p class="p9">(</p>
<p class="p9">{</p>
<p class="p9"><span class="s2">var</span> concat, control, input, amp;</p>
<p class="p6"><br></p>
<p class="p9">input= <span class="s2">SinOsc</span>.ar(2)*</p>
<p class="p9"><span class="s2">Mix</span>(<span class="s2">Gendy3</span>.ar(3,5,1.0,1.0,(<span class="s2">Array</span>.fill(5,{<span class="s2">LFNoise0</span>.kr(1.3.rand,1,2)})*<span class="s2">MouseY</span>.kr(100,3780,<span class="s3">'exponential'</span>)),<span class="s2">MouseY</span>.kr(0.01,0.05),<span class="s2">MouseY</span>.kr(0.001,0.016),5,mul:0.1));</p>
<p class="p6"><br></p>
<p class="p9">control=<span class="s2">SoundIn</span>.ar;<span class="Apple-converted-space"> </span></p>
<p class="p6"><br></p>
<p class="p9">amp=<span class="s2">Amplitude</span>.ar(control);</p>
<p class="p6"><br></p>
<p class="p9">concat= <span class="s2">Concat</span>.ar(control,input,1.0,1.0,1.0,<span class="s2">MouseX</span>.kr(0.0,0.1),0,1.0,0.0,1.0,1.0);</p>
<p class="p6"><br></p>
<p class="p9"><span class="s2">Out</span>.ar(0,<span class="s2">Pan2</span>.ar(10*concat*amp,0.0))}.play</p>
<p class="p9">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">//granulator</p>
<p class="p9">(</p>
<p class="p9">{</p>
<p class="p9"><span class="s2">var</span> concat, control, input;</p>
<p class="p6"><br></p>
<p class="p9">control= <span class="s2">Saw</span>.ar(<span class="s2">SinOsc</span>.kr(<span class="s2">LFNoise0</span>.kr(<span class="s2">MouseY</span>.kr(0.01,1),3,4.5),0,10,<span class="s2">MouseY</span>.kr(12,100)));</p>
<p class="p6"><br></p>
<p class="p9">input=<span class="s2">PlayBuf</span>.ar(1,b.bufnum,<span class="s2">BufRateScale</span>.kr(b.bufnum), loop:1);<span class="Apple-converted-space"> </span></p>
<p class="p6"><br></p>
<p class="p9">concat= <span class="s2">Concat</span>.ar(control,input,2.0,2.0,2.0,<span class="s2">MouseX</span>.kr(0.01,0.1),0,<span class="s2">MouseY</span>.kr(0.0,1.0),1.0,0.5);</p>
<p class="p6"><br></p>
<p class="p9"><span class="s2">Out</span>.ar(0,<span class="s2">Pan2</span>.ar(concat,0.0))}.play</p>
<p class="p9">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p8"><span class="s1">b = </span><span class="s2">Buffer</span><span class="s1">.read(s,</span>"sounds/break2"<span class="s1">);</span></p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p7">//beat resynthesis match by ZCR and spec centroid</p>
<p class="p9">(</p>
<p class="p9"><span class="s2">SynthDef</span>(<span class="s3">\concatexample2</span>, {<span class="s2">arg</span> bufnum, freeze=0;</p>
<p class="p9"><span class="s2">var</span> concat, control, input, amp;</p>
<p class="p6"><br></p>
<p class="p9">input= <span class="s2">SoundIn</span>.ar;</p>
<p class="p6"><br></p>
<p class="p9">control=<span class="s2">PlayBuf</span>.ar(1,bufnum,<span class="s2">BufRateScale</span>.kr(bufnum), loop:1);<span class="Apple-converted-space"> </span></p>
<p class="p6"><br></p>
<p class="p9">amp=<span class="s2">Amplitude</span>.ar(control);</p>
<p class="p6"><br></p>
<p class="p9">concat= <span class="s2">Concat</span>.ar(control,input,5.0,5.0,5.0,<span class="s2">MouseX</span>.kr(0.0,0.1),freeze,<span class="s2">MouseY</span>.kr(0.0,1.0),0.0,1.0);</p>
<p class="p6"><br></p>
<p class="p9"><span class="s2">Out</span>.ar(0,<span class="s2">Pan2</span>.ar(10*concat*amp,0.0))</p>
<p class="p9">}).add;</p>
<p class="p9">)</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
<p class="p10"><span class="s1">a=</span><span class="s2">Synth</span><span class="s1">(</span>\concatexample2<span class="s1">,[</span>\bufnum<span class="s1">, b.bufnum]);</span></p>
<p class="p6"><br></p>
<p class="p7"><span class="s1">a.set(</span><span class="s3">\freeze</span><span class="s1">, 1); </span>//set this on or off to stay with a set of collected sounds</p>
<p class="p6"><br></p>
<p class="p7"><span class="s1">a.set(</span><span class="s3">\freeze</span><span class="s1">, 0); </span>//set this on or off to stay with a set of collected sounds</p>
<p class="p6"><br></p>
<p class="p6"><br></p>
</body>
</html>
